package headline

import (
	"api/pkg"
	"fmt"
	"github.com/gin-gonic/gin"
	"log"
	"net/http"
)

func UploadVideoFile(c *gin.Context) {
	// 单文件
	file, _ := c.FormFile("file")
	log.Println(file.Filename)
	dst := "../api/mp4/" + file.Filename
	// 上传文件至指定的完整文件路径
	c.SaveUploadedFile(file, dst)
	//调用云上传
	ossUrl := pkg.UploadOssFile(dst, file.Filename)
	c.JSON(http.StatusOK, gin.H{
		"code":    http.StatusOK,
		"message": fmt.Sprintf("'%s' uploaded!", file.Filename),
		"url":     ossUrl,
	})
}
